package com.example.service;

import java.io.*;
import java.net.Socket;

public class OnlyPathwayCommander {
    public void showFileContent(String filePath) {
        // 向服务器端发送请求，获取文件内容
        try {
            Socket socket = new Socket("服务器IP", 8888);
            OutputStream outputStream = socket.getOutputStream();
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));

            // 发送show命令及文件路径
            writer.write("show " + filePath);
            writer.newLine();
            writer.flush();

            // 接收服务器端返回的文件内容
            InputStream inputStream = socket.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

            String fileContent = reader.readLine();
            System.out.println("文件内容：" + fileContent);
            // 这里假设服务器返回的是文件内容，根据实际情况处理

            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

